package com.example.taobaounion.utils;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.example.taobaounion.model.bean.IBaseInfo;
import com.example.taobaounion.presenter.ITicketPresenter;
import com.example.taobaounion.ui.activity.TicketActivity;

public class TicketUtils {

    public static void toTicketPage(Context context,IBaseInfo baseInfo){
        //特惠列表内容被点击
        //处理数据
        String title = baseInfo.getTitle();
        //详情的地址
        //String url = item.getClick_url();
        String url = baseInfo.getUrl();
        if(TextUtils.isEmpty(url)){
            url=baseInfo.getUrl();
        }
        String cover = baseInfo.getCover();
        //在跳转Activity前就将数据加载好，等到了Activity数据加载速度能够快一点
        //拿到ticketPresenter去加载数据
        ITicketPresenter ticketPresenter = PresenterManager.getInstance().getTicketPresenter();
        ticketPresenter.getTicket(title,url,cover);//这里可能会出现问题，就是getTicket方法如果执行过快，会
        //还没startActivity去注册callback就执行完了，造成无法加载数据到TicketActivity，无法更新界面
        context.startActivity(new Intent(context, TicketActivity.class));
    }
}
